<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.w3.org/1999/xhtml" >
<head>
    <meta charset="UTF-8">
    <title>娱乐审批</title>
    <script src="/js/jquery-2.1.1.min.js"></script>


    <link rel="stylesheet" href="/js/easyui1.5/themes/icon.css">
    <link rel="stylesheet" href="/js/easyui1.5/themes/default/easyui.css">
    <script src="/js/easyui1.5/jquery.easyui.min.js"></script>
</head>
<script type="text/javascript"  th:inline="none">


    $(function () {
        $('#add_div').dialog('close');
        queryYuLeSP();
    })


    function queryYuLeSP(){


        $("#dg").datagrid({

            url:'/user/queryYuLeSP',
            striped:true,
            pagination:true,
            toolbar:"#gongneng",
            pageList:[1,2,3,4,5,7,10],
            pageSize:5,
            checkOnSelect:false,
            columns:[[
                {field:'xxx',title:'xx',width:100,checkbox:true,align:'center'},
                {field:'imgurl',title:'封面图片',width:100,align:'center',
                    formatter:function(value,row,index){
                        return "<img width='77' src='"+value+"'>";
                    }
                },
                {field:'zhuozhe',title:'文章作者',width:100,align:'center'},
                {field:'tutitle',title:'文章标题',width:100,align:'center' },
                {field:'shijian',title:'申请时间',width:100,align:'center',
                    formatter: function(value,row,index){
                        //        console.log("==>"+value)
                        //字符串 转成日期对象
                        var mydate = new Date(value)//格式化日期
                        var str = mydate.toLocaleDateString()//日期对象的方法
                        return str;
                    }},


                {field:'bzname',title:'推荐人',width:100,align:'center',},
                {field:'aaaa',title:'操作',width:300,align:'center',
                    formatter:function(value,row,index){
                        var content = " <a href='JavaScript:tongGuo("+row.id+")' >通过</a> ";
                        content += " <a href='JavaScript:JuJueTuiJian("+row.id+")' >拒绝</a> ";
                        return content;
                    }
                }
            ]]

        })
    }

    function updateUserState(id) {

        $.ajax({
            url:"/user/updateUserState",
            type:"POST",
            data:{userId:id,state:2},
            success:function(pageUtil){
                getUser();
            },
            error:function(){
                alert("失败了");
            }
        })

    }

    function JuJueTuiJian(ids) {

        $.ajax({
            url:"/user/JuJueTuiJian",
            type:"POST",
            data:{ids:ids},
            success:function(res){
                queryYuLeSP();

            },
            error:function(){
                alert("失败了");
            }
        })
    }

    function setEvent(){

        var rows = $("#dg").datagrid("getChecked");
        var ids = "";
        $.each(rows,function(index,obj){
            ids += ids==""?obj.userId:","+obj.userId;
        });

        if(ids!=null&&ids!=""){
            delUser(ids);
        }


    }

    function tongGuo(ids){


        $.ajax({
            url:"/user/tongGuo",
            type:"POST",
            data:{ids:ids},
            success:function(res){
                queryYuLeSP();

                $.messager.show({
                    title:'消息',
                    msg:'审批通过!!',
                    timeout:5000,
                    showType:'slide'
                });

            },
            error:function(){
                alert("失败了");
            }
        });


    }


    function updateUser(){

        var formData = new FormData($("form")[0]);

        $.ajax({

            url:"/user/updateUser",
            data:formData,
            type:"POST",
            cache: false,
            contentType: false,
            processData: false,
            success:function(result){
                $('#add_div').dialog('close');
                getUser();
            },
            error:function(){
                alert("出错啦!!!");
            }
        })

    }



</script>


<body>

<div id="gongneng">
</div>
<table id="dg" fit="true"></table>
<div id="add_div"  class="easyui-dialog" title="新增用户" style="width:600px;height:300px"
     data-options="iconCls:'icon-save',resizable:true,modal:true,
			buttons:[{
				text:'保存',
				iconCls:'icon-ok',
				handler:function(){
					 updateUser()//调用另一个方法
				}
			},{
				text:'关闭',
				iconCls:'icon-no',
				handler:function(){
				   $('#add_div').dialog('close');
				}
			}]">

    <form id="user-from">
        <input type="hidden" name="userId">

        <table>
            <tr>
                <td>账号</td>
                <td><input name="userAccout"></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input name="userPwd"></td>
            </tr>
            <tr>
                <td>昵称</td>
                <td><input name="nickName"></td>
            </tr>
            <tr>
                <td>年龄</td>
                <td><input name="userAge"></td>
            </tr>
            <tr>
                <td>手机号</td>
                <td><input name="phone"></td>
            </tr>
            <tr>
                <td>图片</td>
                <td>
                    <input type="file" name="fileName">
                    <input type="hidden" name="img">
                    <img id="testimg">
                </td>
            </tr>
        </table>
    </form>


</div>

</body>
</html>